package me.itsoo.artemis.framework.ioc.context;

import me.itsoo.artemis.framework.ioc.exception.NoSuchBeanException;
import me.itsoo.artemis.framework.ioc.factory.CacheableBeanFactory;

/**
 * AbstractApplicationContext
 *
 * @author zxy
 * @version 0.0.1
 * @since 2023/6/6
 */
public abstract class AbstractApplicationContext implements ApplicationContext {

    /**
     * 获取 BeanFactory
     *
     * @return CacheableBeanFactory
     */
    protected abstract CacheableBeanFactory getBeanFactory();

    @Override
    public Object getBean(String beanName) throws NoSuchBeanException {
        return getBeanFactory().getBean(beanName);
    }

    @Override
    public <T> T getBean(Class<T> beanClass) throws NoSuchBeanException {
        return getBeanFactory().getBean(beanClass);
    }

    @Override
    public boolean containsBean(String beanName) {
        return getBeanFactory().containsBean(beanName);
    }
}
